//获取应用实例
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        listData: [{}],
        type: 0,

    },

    //宣传活动请求数据
    getlistData() {
        let _this = this;
        let userInfo = wx.getStorageSync('userInfo');
        let user_id = userInfo.user_id;
        app.util.ajax({
            url: 'Article/index',
            data: {
                user_id: user_id,
            },
            success: function(res) {
                _this.setData({
                    listData: res
                })
            }
        })
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.getlistData();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function(e) {
        let titles = e.target.dataset.title
        return {
            title: titles,
            path: '/pages/index/index'
        }
    },
    // 是否点赞
    isPraise: function(e) {
        let itemId = e.currentTarget.dataset.id,
            state = e.currentTarget.dataset.state ? 0 : 1,
            _this = this;
        app.util.ajax({
            url: 'Article/zambia',
            data: {
                id: itemId,
                user_id: app.globalData.userInfo.user_id,
                state: state
            },
            success: function(data) {
                _this.getlistData();

            }
        })
    },
    // 查看详情
    seeDetail:function(e){
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url:"/pages/index/Publicity_campaign/propagandaDetail/propagandaDetail?id="+id
        })
    },
    seeComment:function(e){
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
          url: "/pages/index/Publicity_campaign/propagandaDetail/propagandaDetail?id=" + id + '&comment=omment'
        })
    }
})